﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Model.Entities
{
    public class SystemContext
    {
        private static PublisinosEntities context;

        public static PublisinosEntities CurrentContext
        {
            get
            {
                if (HttpContext.Current != null)
                {
                    PublisinosEntities ctx = (PublisinosEntities)HttpContext.Current.Items["SystemContext"];

                    if (ctx == null)
                    {

                        ctx = new PublisinosEntities();

                        HttpContext.Current.Items["SystemContext"] = ctx;
                    }

                    return (PublisinosEntities)ctx;
                }
                else
                {
                    if (context == null)
                        context = new PublisinosEntities();

                    return context;

                }
            }
        }
    }
}